package com.plugin.buildsrc.config

import com.android.build.gradle.api.BaseVariant
import org.gradle.api.Project

class VariantBuildConfiguration {
    static List<File> variants
    static void init(Project project) {
        variants = project.rootProject.file("./").listFiles().findAll {File file->
            return file.name.endsWith(".properties")
        }
    }

    private static List<File> getVariants() {
        return variants
    }

    static void config(Project project, BaseVariant variant) {
        try {
            getVariants().each { File file ->
                def configName = file.name.toLowerCase()
                if (configName.contains(variant.productFlavors.get(1).name.toLowerCase()) && configName.contains(variant.productFlavors.get(0).name.toLowerCase())) {
                    new Environment(project, file, variant).config()
                }
            }
        } catch (Exception e) {
        }


    }
}